package org.explugin.lang.parser;

import com.intellij.lang.ASTNode;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.PsiParser;
import com.intellij.psi.tree.IElementType;
import org.explugin.lang.parser.util.Parsing;
import org.jetbrains.annotations.NotNull;

public class ExParser implements PsiParser {

    @NotNull
    @Override
    public ASTNode parse(IElementType iElementType, PsiBuilder psiBuilder) {
        final PsiBuilder.Marker rootMarker = psiBuilder.mark();

        while (!psiBuilder.eof()) {
            Parsing.parse(psiBuilder);
        }

        rootMarker.done(iElementType);

        return psiBuilder.getTreeBuilt();
    }
}
